package com.xcc.dataStructures.leetcode;

/**
 * 给定一个数m，求大于这个数最小的2的n次幂
 */
public class Demo014_2miForN {

    public static void main(String[] args) {
//        int n = getN(7, 0);
        int n = getN(15);
        System.out.println(n);
    }

    public static int getN(int m, int count) {
        if (m<0) {
            return 0;
        }
        count++;
        if (m / 2 == 0) {
            return count;
        } else {
            return getN(m / 2, count);
        }
    }

    public static int getN(int m) {
        if (m<0) {
            return 0;
        }
        int count = 0;
        int tmp = m ;
        while (tmp != 0) {
            count++;
            tmp = tmp / 2;
        }
        return count;
    }

}
